#pragma once

#include <string>
#include "TTToeState.h"

#define PLAYER_1_		'o'		// Current player
#define PLAYER_2_		'x'		// Computer or remote player
#define PLAYER_NONE		' '		// Free cell

namespace SmartTTToe {
	class TTToeBoard {
	private:
		int boardSize;		// The size of the board
		int stepCount;		// Step counter
		int branches;
		int maxDepth;
		char** boardMap;	// The board map containing 'o' or 'x'
		int** evalBoard;	// Temporal evaluation board
		TTToeState*** stateArray;	// Temporal states for GetMaxNode function
		std::string* xCases;	// { "\\sxx\\s", "\\sxxxo", "oxxx\\s", "\\sxxx\\s", "\\sxxxxo", "oxxxx\\s", "\\sxxxx\\s", "xxxxx" };
		std::string* oCases;	// { "\soo\s", "\sooox", "xooo\s", "\sooo\s", "\soooox", "xoooo\s", "\soooo\s", "ooooo" };
		int* regex_points;
		int* TScore;
		int* KScore;
		void evaluateBoard(char** cells, char player);
		TTToeState* GetMaxNode();
		int Evaluate();
		int MaxEvaluatedValue(TTToeState* state, int alpha, int beta, int depth);
		int MinEvaluatedValue(TTToeState* state, int alpha, int beta, int depth);
		TTToePosition* Solve();

	public:
		TTToeBoard(int size);
		~TTToeBoard(void);
		int insert(int x, int y, bool turn);
		int getBranches();
		void setBranches(int branches);
		int getMaxDepth();
		void setMaxDepth(int maxDepth);
	};
}	// namespace SmartTTToe

